/**
Entity.hpp
Title: Binge Entity Header File
Descr: Entity Class

Copyright (c) 2010, Brant Ryan Anderson
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <ORGANIZATION> nor the names of its contributors
      may be used to endorse or promote products derived from this software
      without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/

#ifndef BINGE_ENTITY_HPP
#define BINGE_ENTITY_HPP

#include <iostream>
#include <string>
#include <SFML/Graphics.hpp>
#include "../../binge/enum.hpp"
#include "../../binge/core/Timer.hpp"

namespace binge
{

class Entity {
public:
	Entity(void);
	virtual ~Entity(void) {  }

	virtual void move(void) = 0;
	virtual void animate(void) = 0;
	virtual void draw(void) = 0;

	void setID(int value) { id = value; }
	int getID(void) { return id; }

	std::string getName(void) { return name; }
	void setName(std::string value) { name = value; }

	bool getVisible(void) { return visible; }
	void setVisible(bool value) { visible = value; }

	bool getAlive(void) { return alive; }
	void setAlive(bool value) { alive = value; }

	int getLifetime(void) { return lifetimeLength; }
	void setLifetime(int value) { lifetimeLength = value; }
	bool lifetimeExpired(void) { return lifetimeTimer.Stopwatch(lifetimeLength); }

	ObjectType getObjectType(void) { return objectType; }
	void setObjectType(ObjectType type) { objectType = type; }

	// Collision Rectangle, to be set by user (defaults everyting to 0)
	sf::Rect<float> collisionRect;

	bool isCollidable() { return collidable; }
	void setCollidable(bool value) { collidable = value; }
	CollisionType getCollisionMethod() { return collisionMethod; }
	void setCollisionMethod(CollisionType type) { collisionMethod = type; }

	int getColRectOffsetX(void) { return colRectOffsetX; }
	void setColRectOffsetX(int ox) { colRectOffsetX = ox; }
	int getColRectOffsetY(void) { return colRectOffsetY; }
	void setColRectOffsetY(int oy) { colRectOffsetY = oy; }

	int getColRectWidth(void) { return colRectWidth; }
	void setColRectWidth(int crw) { colRectWidth = crw; }
	int getColRectHeight(void) { return colRectHeight; }
	void setColRectHeight(int crh) { colRectHeight = crh; }

	void setCollisionRect(sf::Rect<float> rect) { collisionRect = rect; }
	void setCollisionRect(int left,int top,int right,int bottom)
	{
		collisionRect.Left = static_cast<float>(left);
		collisionRect.Top = static_cast<float>(top);
		collisionRect.Right = static_cast<float>(right);
		collisionRect.Bottom = static_cast<float>(bottom);
	}
	void setCollisionRect(float left,float top,float right,float bottom)
	{
		collisionRect.Left = left;
		collisionRect.Top = top;
		collisionRect.Right = right;
		collisionRect.Bottom = bottom;
	}
	float getScale(void) { return scale; }
	void setScale(float value) { scale = value; }


private:
	int id;
	std::string name;
	bool visible;
	bool alive;
	ObjectType objectType;
	int lifetimeLength;
	Timer lifetimeTimer;
	float scale;

	// collision stuff
	bool collidable;
	CollisionType collisionMethod;
	int colRectOffsetX;
	int colRectOffsetY;
	int colRectWidth;
	int colRectHeight;
};

} // namespace

#endif
